
using System;
using System.Collections;
using System.Web.UI.WebControls;

namespace GiftNet.Model
{
    #region ShipCompany Model -(by fangyifeng at 2010-12-27 11:16:15)

    /// <summary>
    /// ShipCompany object'ShipCompany'.
    /// </summary>
    public class ShipCompany : System.IComparable
    {
        #region Member Variables

        protected Guid _id;
        protected string _companyName;
        protected DateTime _addTime;
        protected decimal _dHLRuelRate;
        protected decimal _uPSRuelRate;
        protected decimal _eMSRuelRate;
        protected decimal _aRAMEXRuelRate;
        protected decimal _fEDEXRuelRate;
        protected decimal _tNTRuelRate;
        protected string _memo;
        protected string _shipnamememo;

        protected static String _sortExpression = "Id";
        protected static SortDirection _sortDirection = SortDirection.Ascending;

        #endregion

        #region Constructors

        public ShipCompany() { }

        public ShipCompany(string companyName, DateTime addTime, decimal dHLRuelRate, decimal uPSRuelRate, decimal eMSRuelRate, decimal aRAMEXRuelRate, decimal fEDEXRuelRate, decimal tNTRuelRate, string memo)
        {
            this._companyName = companyName;
            this._addTime = addTime;
            this._dHLRuelRate = dHLRuelRate;
            this._uPSRuelRate = uPSRuelRate;
            this._eMSRuelRate = eMSRuelRate;
            this._aRAMEXRuelRate = aRAMEXRuelRate;
            this._fEDEXRuelRate = fEDEXRuelRate;
            this._tNTRuelRate = tNTRuelRate;
            this._memo = memo;
        }

        #endregion

        #region Public Properties

        public virtual string ShipNameMemo
        {
            get { return _shipnamememo; }
            set
            {
                if (value != null && value.Length > 200)
                    throw new ArgumentOutOfRangeException("Invalid value for ShipNameMemo", value, value.ToString());
                _shipnamememo = value;
            }
        }


        public virtual Guid Id
        {
            get { return _id; }
            set { _id = value; }
        }

        public virtual string CompanyName
        {
            get { return _companyName; }
            set
            {
                if (value != null && value.Length > 50)
                    throw new ArgumentOutOfRangeException("Invalid value for CompanyName", value, value.ToString());
                _companyName = value;
            }
        }

        public virtual DateTime AddTime
        {
            get { return _addTime; }
            set { _addTime = value; }
        }

        public virtual decimal DHLRuelRate
        {
            get { return _dHLRuelRate; }
            set { _dHLRuelRate = value; }
        }

        public virtual decimal UPSRuelRate
        {
            get { return _uPSRuelRate; }
            set { _uPSRuelRate = value; }
        }

        public virtual decimal EMSRuelRate
        {
            get { return _eMSRuelRate; }
            set { _eMSRuelRate = value; }
        }

        public virtual decimal ARAMEXRuelRate
        {
            get { return _aRAMEXRuelRate; }
            set { _aRAMEXRuelRate = value; }
        }

        public virtual decimal FEDEXRuelRate
        {
            get { return _fEDEXRuelRate; }
            set { _fEDEXRuelRate = value; }
        }

        public virtual decimal TNTRuelRate
        {
            get { return _tNTRuelRate; }
            set { _tNTRuelRate = value; }
        }

        public virtual string Memo
        {
            get { return _memo; }
            set
            {
                if (value != null && value.Length > 100)
                    throw new ArgumentOutOfRangeException("Invalid value for Memo", value, value.ToString());
                _memo = value;
            }
        }

        public static String SortExpression
        {
            get { return _sortExpression; }
            set { _sortExpression = value; }
        }

        public static SortDirection SortDirection
        {
            get { return _sortDirection; }
            set { _sortDirection = value; }
        }
        #endregion

        #region IComparable Methods
        public virtual int CompareTo(object obj)
        {
            if (!(obj is ShipCompany))
                throw new InvalidCastException("This object is not of type ShipCompany");

            int relativeValue;
            switch (SortExpression)
            {
                case "Id":
                    relativeValue = this.Id.CompareTo(((ShipCompany)obj).Id);
                    break;
                case "CompanyName":
                    relativeValue = this.CompanyName.CompareTo(((ShipCompany)obj).CompanyName);
                    break;
                case "AddTime":
                    relativeValue = this.AddTime.CompareTo(((ShipCompany)obj).AddTime);
                    break;
                case "DHLRuelRate":
                    relativeValue = this.DHLRuelRate.CompareTo(((ShipCompany)obj).DHLRuelRate);
                    break;
                case "UPSRuelRate":
                    relativeValue = this.UPSRuelRate.CompareTo(((ShipCompany)obj).UPSRuelRate);
                    break;
                case "EMSRuelRate":
                    relativeValue = this.EMSRuelRate.CompareTo(((ShipCompany)obj).EMSRuelRate);
                    break;
                case "ARAMEXRuelRate":
                    relativeValue = this.ARAMEXRuelRate.CompareTo(((ShipCompany)obj).ARAMEXRuelRate);
                    break;
                case "FEDEXRuelRate":
                    relativeValue = this.FEDEXRuelRate.CompareTo(((ShipCompany)obj).FEDEXRuelRate);
                    break;
                case "TNTRuelRate":
                    relativeValue = this.TNTRuelRate.CompareTo(((ShipCompany)obj).TNTRuelRate);
                    break;
                case "Memo":
                    relativeValue = (this.Memo != null) ? this.Memo.CompareTo(((ShipCompany)obj).Memo) : -1;
                    break;
                default:
                    goto case "Id";
            }
            if (ShipCompany.SortDirection == SortDirection.Ascending)
                relativeValue *= -1;
            return relativeValue;
        }
        #endregion
    }

    #endregion
}
